import java.io.IOException;

public class FacadeFileManager {
    private FileHandler fileHandler;

    public FacadeFileManager(String filePath) {
        this.fileHandler = new FileHandler(filePath);
    }

    public boolean fileExists() {
        return fileHandler.fileExists();
    }

    public void createFile() {
        try {
            fileHandler.createFile();
        } catch (IOException e) {
            System.out.println("创建文件时出错：" + e.getMessage());
        }
    }

    public void deleteFile() {
        fileHandler.deleteFile();
    }

    public String readFile() {
        try {
            return fileHandler.readFile();
        } catch (IOException e) {
            System.out.println("读取文件时出错：" + e.getMessage());
            return null;
        }
    }

    public void writeFile(String data) {
        try {
            fileHandler.writeFile(data);
        } catch (IOException e) {
            System.out.println("写入文件时出错：" + e.getMessage());
        }
    }

    public void writeXorEncryptedFile(String data, String key) {
        try {
            fileHandler.writeXorEncryptedFile(data, key);
        } catch (IOException e) {
            System.out.println("写入加密文件时出错：" + e.getMessage());
        }
    }

    public String readXorEncryptedFile(String key) {
        try {
            return fileHandler.readXorEncryptedFile(key);
        } catch (IOException e) {
            System.out.println("读取加密文件时出错：" + e.getMessage());
            return null;
        }
    }
}
